package jmine.tec.web.wicket.component.command.button;

import static jmine.tec.web.wicket.pages.form.WebFormPagesMessages.LABEL_BUTTON_NEW;

import org.apache.wicket.Page;
import org.apache.wicket.markup.html.form.Button;

/**
 * {@link ButtonCommand} que representa um botão de "Novo"
 * 
 * @author Rafael Volpato
 * @date Aug 12, 2011
 */
public class NewCommand extends AbstractButtonCommand {

    private final NewCommandHandler handler;

    /**
     * Construtor.
     * 
     * @param handler {@link NewCommandHandler}
     */
    public NewCommand(NewCommandHandler handler) {
        this.handler = handler;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Page execute() {
        return this.handler.createNewPage();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getLabel() {
        return LABEL_BUTTON_NEW.create().getMessage();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Button createButtonComponent(String id) {
        Button buttonNew = super.createButtonComponent(id);
        buttonNew.setDefaultFormProcessing(false);
        return buttonNew;
    }
}
